package 剑指offer_leetcode;

/**
 * JZ57和为S的两个数字
 */
public class 剑指Offer57_和为s的两个数字 {
    public int[] twoSum(int[] nums, int target) {
        int left = 0,right = nums.length-1;
        while(left<right){
            if(nums[left]+nums[right]==target){
                return new int[]{nums[left],nums[right]};
            }else if(nums[left]+nums[right]<target){
                left++;
            }else{
                right--;
            }
        }
        return new int[0];
    }

}
